@extends('common.admin_template')

@section('content')
    <div class="boxWidth">
        <h3>发布私信</h3>
        @include('common.notice_msg')
        <form method="post" action="{{url('admin/message/save')}}">
        <input type="hidden" name="_token" value="{{ csrf_token() }}">
        <div class="row editFormItem">
            <div class="col-xs-3"><span>接收用户ID</span></div>
            <div class="col-xs-8" id="MessageNameBox"><input type="text" class="form-control" id="MessageName" name="Message[get_user]" value="{{$Message?$Message->post_user:''}}"><div class="addInputNotice">请输入用户ID，如发布公告请填写0</div><span><a
                          target="_blank"  href="{{url('admin/users')}}">查询用户ID</a></span></div>
        </div>
        <div class="row editFormItem">
            <div class="col-xs-3"><span>内容</span></div>
            <div class="col-xs-8" id="MessageContentBox"><textarea type="text" class="form-control" id="MessageContent" name="Message[content]" ></textarea><div class="addInputNotice">请输入内容</div></div>
        </div>
        @if(!$Message)
        <div class="row editFormItem">
            <div class="col-xs-3"><span>是否发布为公告</span></div>
            <div class="col-xs-8"><input class="addCheckboxBtn editCheckboxBtn" type="checkbox"  name="Message[more]"><div class="addInputNotice editInputNotice">选择发布公告，所用用户都会收到公告提醒</div></div>
        </div>
        @endif
        <div class="row editFormItem">
            <div class="col-xs-3"><button class="btn btn-primary addInputBtn" type="submit" id="formSubmit">添加新私信</button></div>
            <div class="col-xs-8"></div>
        </div>
        </form>
    </div>
@stop
@section('js')
    <script>
        (function () {
            $('#formSubmit').on('click',function (e) {
                var sub = 0;
                if(!$('#MessageName').val().replace(/(^\s*)|(\s*$)/g, "")){
                    $('#MessageNameBox').addClass('has-error');
                    sub = 1;
                }
                if(!$('#MessageContent').val().replace(/(^\s*)|(\s*$)/g, "")){
                    $('#MessageContentBox').addClass('has-error');
                    sub = 1;
                }
                if(sub){
                    e.preventDefault();
                }
            })
        })();
    </script>
@stop